#include "umlcardinality.h"

UmlCardinality::UmlCardinality()
{
}

UmlCardinality::UmlCardinality(QString lowerBound, QString upperBound) :
        _lowerBound(lowerBound),
        _upperBound(upperBound)
{

}

QString UmlCardinality::lowerBound()
{
    return this->_lowerBound;
}

void UmlCardinality::setLowerBound(QString lowerBound)
{
    this->_lowerBound = lowerBound;
}

QString UmlCardinality::upperBound()
{
    return this->_upperBound;
}

void UmlCardinality::setUpperBound(QString upperBound)
{
    this->_upperBound = upperBound;
}

QString UmlCardinality::toUmlString()
{
    if (this->_lowerBound.isEmpty() || this->_upperBound.isEmpty()) {
        return QString();
    }

    else if (this->_lowerBound == "n" && this->_upperBound == "n") {
        return QString("n");
    }

    else if (this->_lowerBound == this->_upperBound) {
        return this->_lowerBound;
    }

    return QString("%1 ... %2").arg(this->_lowerBound).arg(this->_upperBound);
}

bool UmlCardinality::isNull()
{
    return this->_lowerBound.isNull() || this->_upperBound.isNull() || this->_lowerBound.isEmpty() || this->_upperBound.isEmpty();
}

bool UmlCardinality::operator ==(UmlCardinality cardinality) {
    return this->_lowerBound == cardinality.lowerBound() && this->_upperBound == cardinality.upperBound();
}
